<?php 
global $_GPC, $_W;
$GLOBALS['frames'] = $this->getMainMenu();
$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
$status=$_GPC['status'];
load()->func('tpl');
$pageindex = max(1, intval($_GPC['page']));
$pagesize=10;
$where=' WHERE  uniacid=:uniacid  ';
$data[':uniacid']=$_W['uniacid'];
if(isset($_GPC['keywords'])){
    $where.="  and (cate_name LIKE  concat('%', :name,'%') or address LIKE  concat('%', :name,'%'))";
    $data[':name']=$_GPC['keywords']; 
    // $type='all';  
}

$sql="SELECT * FROM ".tablename('snx_school') .$where." ORDER BY create_time desc";
$total=pdo_fetchcolumn("SELECT count(*) FROM ".tablename('snx_school').$where." ORDER BY create_time desc",$data);
$select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
$list=pdo_fetchall($select_sql,$data);
$pager = pagination($total, $pageindex, $pagesize);
//print_r(json_encode($total));die;
if($operation=='delete'){
   $roe = pdo_getall("snx_coursecate",array('school_id'=>$_GPC['id']),array('id'));
  if (!empty($roe)) {
          message('该校区下有学级暂时无法删除','','error');
  }else{
    $res=pdo_delete('snx_school',array('id'=>$_GPC['id']));
    if($res){
      message('删除成功',$this->createWebUrl('school',array()),'success');
    }else{
      message('删除失败','','error');
    }
  }
}
if($_GPC['op']=='change'){
   $res=pdo_update('snx_school',array('status'=>$_GPC['status']),array('id'=>$_GPC['id']));
    if($res){
        message('操作成功',$this->createWebUrl('school',array()),'success');
    }else{
        message('操作失败','','error');
    }
}
include $this->template('web/school');

 ?>